package com.hadoop.project.mvc.controller;

import com.hadoop.project.entity.po.TabRank;
import com.hadoop.project.entity.query.TabRankQuery;
import com.hadoop.project.entity.vo.ResponseVO;
import com.hadoop.project.mvc.service.TabRankService;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * @Description: Controller
 * @author:alexmaodali
 * @date:2025/4/13
 */
@RestController
@RequestMapping("/tabRank")
@ApiOperation(value = "标签排名接口")
public class TabRankController extends ABaseController {

	@Resource
	private TabRankService tabRankService;

	/**
	 * 根据条件分页查询
	 */
	@RequestMapping("loadDataList")
	public ResponseVO loadDataList(TabRankQuery query) {
		return getSuccessResponseVO(tabRankService.findListByPage(query));
	}

	/**
	 * 新增
	 */
	@RequestMapping("add")
	public ResponseVO add(TabRank bean) {
		this.tabRankService.add(bean);
		return getSuccessResponseVO(null);
	}

	/**
	 * 批量新增
	 */
	@RequestMapping("addBatch")
	public ResponseVO addBatch(@RequestBody List<TabRank> listBean) {
		for(TabRank tabRank : listBean){
			System.out.println("tabRank = " + tabRank);
			System.out.println("tabRank.getId() = " + tabRank.getId());
			System.out.println("tabRank.getTname() = " + tabRank.getTname());
			System.out.println("tabRank.getCnt() = " + tabRank.getCnt());
		}
		this.tabRankService.addBatch(listBean);
		return getSuccessResponseVO(null);
	}

	/**
	 * 批量新增或修改
	 */
	@RequestMapping("addOrUpdateBatch")
	public ResponseVO addOrUpdateBatch(@RequestBody List<TabRank> listBean) {
		this.tabRankService.addOrUpdateBatch(listBean);
		return getSuccessResponseVO(null);
	}

	/**
	 * 根据Id查询
	 */
	@RequestMapping("getTabRankById")
	public ResponseVO  getTabRankById(Long id) {
		return getSuccessResponseVO(this.tabRankService.getTabRankById(id));
	}

	/**
	 * 根据Id更新
	 */
	@RequestMapping("updateTabRankById")
	public ResponseVO updateTabRankById(TabRank bean,Long id) {
		this.tabRankService.updateTabRankById(bean,id);
		return getSuccessResponseVO(null);
	}

	/**
	 * 根据Id删除
	 */
	@RequestMapping("deleteTabRankById")
	public ResponseVO deleteTabRankById(Long id) {
		this.tabRankService.deleteTabRankById(id);
		return getSuccessResponseVO(null);
	}


}
